package com.snake.springboot.authority.service.assembler;

import com.snake.springboot.authority.api.model.AuthInterfaceModel;
import com.snake.springboot.authority.dao.mybatis.entity.AuthInterfaceDO;
import org.snake.common.code.SerialNumberGeneratorFactory;
import org.snake.common.utils.PropertyUtils;

/**
 * 类 {@code AuthInterfaceAssembler}  <br> .
 * <p>服务接口模型组装器
 * 创建时间：2024/5/27 11:53
 *
 * @author Yzhui
 * @see
 */
public class AuthInterfaceAssembler {

    public static AuthInterfaceDO assembleAuthInterfaceDO(AuthInterfaceModel authInterfaceModel, boolean isNew) throws Exception {
        AuthInterfaceDO entity = new AuthInterfaceDO();
        PropertyUtils.copyPropertiesIfNull(entity, authInterfaceModel);
        if (isNew) {
            SerialNumberGeneratorFactory.buildId4Bean(entity, "interfaceId");
        }
        return entity;
    }

    public static AuthInterfaceModel assembleAuthInterfaceModel(AuthInterfaceDO authInterfaceDO) {
        AuthInterfaceModel model = new AuthInterfaceModel();
        PropertyUtils.copyPropertiesIfNull(model, authInterfaceDO);
        return model;
    }


}
